﻿using MimeKit;
using System;

namespace WisDom.Utils
{
    /// <summary>
    /// Copyright (c) 2013-2017 河南恒茂创远科技股份有限公司
    /// 创建人：郭雪峰
    /// 日 期：2018.2.11
    /// 描 述：邮件发送类
    /// </summary>
    public class MailHelper
    {
        private string _mailHost = "";
        private int _port = 0;
        private string _mailAccount = "";
        private string _mailPassword = "";
        public MailHelper(string mailhost,int port,string mailAccount,string mailPassword )
        {
            this._mailHost = mailhost;
            this._port = port;
            this._mailAccount = mailAccount;
            this._mailPassword = mailPassword;
             
        }
         

        public void Send(string formUser,string toUser,string title,string content)
        {
            //var message = new MimeMessage();
            ////获取From标头中的地址列表，添加指定的地址
            //message.From.Add(new MailboxAddress("Joey", "joey@friends.com"));
            ////获取To头中的地址列表，添加指定的地址
            //message.To.Add(new MailboxAddress("Alice", "alice@wonderland.com"));
            ////获取或设置消息的主题
            //message.Subject = "How you doin?";
            //// 创建我们的消息文本，就像以前一样（除了不设置为message.Body）
            //var body = new TextPart("plain")
            //{
            //    Text = @"Hey Alice-- Joey"
            //};
            //// 为位于路径的文件创建图像附件
            //var attachment = new MimePart("image", "gif")
            //{
            //    ContentObject = new ContentObject(File.OpenRead(path), ContentEncoding.Default),
            //    ContentDisposition = new ContentDisposition(ContentDisposition.Attachment),
            //    ContentTransferEncoding = ContentEncoding.Base64,
            //    FileName = Path.GetFileName(path)
            //};
            //// 现在创建multipart / mixed容器来保存消息文本和图像附件
            //var multipart = new Multipart("mixed")
            //{
            //    body, attachment
            //};
            //// 现在将multipart / mixed设置为消息正文 
            //message.Body = multipart;
        }
    }
}
